package com.javabaas.server.novel_server.book.entity;


import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;

import java.util.List;

@CacheConfig(cacheNames = "book")
public interface BookRepository extends MongoRepository<Book, String> {

    List<Book> findByRankId(String rankId, Pageable pageable);

    List<Book> findByMonthRank(String rankId, Pageable pageable);

    List<Book> findByTotalRank(String rankId, Pageable pageable);

    List<Book> findByTitleContainsOrderByLatelyFollowerDesc(String title, Pageable pageable);

    List<Book> findByTagsIsContainingOrderByLatelyFollowerDesc(String tagName, Pageable pageable);

    List<Book> findByAuthorContainsOrderByLatelyFollowerDesc(String author, Pageable pageable);

    List<Book> findByTitleContainsOrAuthorContainsOrderByLatelyFollowerDesc(String s1, String s2, Pageable pageable);

    List<Book> findByGenderContainsAndTypeAndMajorCate(String gender ,String type, String minor, Pageable pageable);

    List<Book> findBy_idIsIn(List<String> ids);


    @Cacheable(key = "'book-' + #p0")
    Book findBy_idIsLike(String id);

}
